package com.yurun.service.impl;

import com.yurun.entity.SiteSetting;
import com.yurun.exception.PersistenceException;
import com.yurun.mapper.SiteSettingMapper;
import com.yurun.service.SiteSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SiteSettingServiceImpl implements SiteSettingService {
    @Autowired
    SiteSettingMapper siteSettingMapper;

    @Override
    public void addSiteSetting(SiteSetting siteSetting){
        if(siteSettingMapper.addSiteSetting(siteSetting)!=1){
            throw new PersistenceException("添加站点设置失败");
        }
    }

    @Override
    public void deleteSiteSettingById(Integer id){
        if(siteSettingMapper.deleteSiteSettingById(id)!=1){
            throw new PersistenceException("删除站点设置失败");
        }
    }

    @Override
    public void updateSiteSetting(SiteSetting siteSetting){
        if(siteSettingMapper.updateSiteSetting(siteSetting)!=1){
            throw new PersistenceException("更新站点设置失败");
        }
    }

    @Override
    public List<SiteSetting> getList(){
        return siteSettingMapper.getList();
    }
}
